#pragma once
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>

//数据存储路径
#define PATH "database.dat"
//姓名最大容量
#define N_NAME 13
//链表数据结构
typedef struct Linker
{
    uint64_t id;
    double money;
    char name[N_NAME];
    struct Linker *next;
} Node, *PNode;

//排序准则，低1位表示升降序，高2位表示比较对象
typedef enum
{
    CT_ASC = 0b000,
    CT_DESC = 0b001,
    
    CT_ID = 0b010,
    CT_NAME = 0b100,
    CT_MONEY = 0b110,
} Criteria;

PNode getHead();
void initModel();
bool linkNode(PNode *node);
void readData(PNode *node, PNode *tail);
void writeData();
void freeData();

PNode get(PNode node, uint64_t id);
void set(PNode target, uint64_t id, char *name, double money);
//排序：使用交换排序算法
void sort(Criteria crit);
bool delete(uint64_t id);
bool compare(PNode current, PNode cmp, Criteria crit);
//停机
void shutdownModel();